import rootStore from "../../stores";
import { Display } from "./Display";

export class Skin {
    name: string = "default";
    slot: SkinSlot[] = [];

    getSlot(name: string) {
        for (const slot of this.slot) {
            if (slot.name === name) {
                return slot;
            }
        }

        return null;
    }

    addSlot(slot: SkinSlot) {
        this.slot.push(slot);
        rootStore.sceneStore.addSkinSlot(slot.name);
    }
}

export class SkinSlot {
    name: string = "";
    display: (Display | null)[] = [];

    getDisplay(name: string) {
        for (const display of this.display) {
            if (display && display.name === name) {
                return display;
            }
        }

        return null;
    }

    public addDisplay(slotName: string, display: Display) {
        this.display.push(display);
        rootStore.sceneStore.addDisplay(slotName, display.name);
        rootStore.sceneStore.dump();
    }
}